
{% if user_type in ['student','teacher'] %}
    {% if type == 'add' %}
        <form action="{{ url('root@adduser') }}" method="post">
            {{ csrf_input }}
            <h2>add {{ user_type }}</h2>
            {{ form.username}}
            {{ form.identity_c}}
            {{ form.name }}
            {{ form.age }}
            {{ form.tel }}
            {{ form.driving_license_type }}
            {{ form.password }}
            <span><input type="submit" class="btn-primary btn btn-sm" value="submit"></span>
        </form>
    {% elif type == 'query' %}
      <table class="table table-striped">
        <thead>
          <tr>
            <th>Username</th>
            <th>Name</th>
            <th>Age</th>
            <th>Tel</th>
            <th>Driving_license</th>
          </tr>
        </thead>
        <tbody>

         {% for i in query %}
            <tr>
            <td>{{ i.username }}</td>
            <td>{{ i.name }}</td>
            <td>{{ i.age }}</td>
            <td>{{ i.tel }}</td>
            <td>{{ i.driving_license_type }}</td>
          </tr>
        {% endfor %}

        </tbody>
      </table>

    {% elif type == 'amend' %}
        <table class="table table-striped">
        <thead>
          <tr>
            <th>Username</th>
            <th>Name</th>
            <th>Age</th>
            <th>Tel</th>
            <th>Driving_license</th>
            <th>Amend</th>
          </tr>
        </thead>
        <tbody>

         {% for i in query %}
            <tr>
            <td>{{ i.username }}</td>
            <td>{{ i.name }}</td>
            <td>{{ i.age }}</td>
            <td>{{ i.tel }}</td>
            <td>{{ i.driving_license_type }}</td>
            <td><button class="btn btn-sm btn-warning" id="amend" data-user="{{ i.username }}" >Amend</button></td>
          </tr>
        {% endfor %}

        </tbody>
      </table>
    {% else %}
        <table class="table table-striped">
        <thead>
          <tr>
            <th>Username</th>
            <th>Name</th>
            <th>Age</th>
            <th>Tel</th>
            <th>Driving_license</th>
            <th>Cancel</th>
          </tr>
        </thead>
        <tbody>

         {% for i in query %}
            <tr>
            <td>{{ i.username }}</td>
            <td>{{ i.name }}</td>
            <td>{{ i.age }}</td>
            <td>{{ i.tel }}</td>
            <td>{{ i.driving_license_type }}</td>
            <td><button class="btn btn-sm btn-danger" id="del" data-user="{{ i.username }}" >Cancel</button></td>
          </tr>
        {% endfor %}

        </tbody>
      </table>
    {% endif %}
{% else %}


{% endif %}
<script>
    $('.container-xl').on('click','#del',function (e){
        const tag = $(this);
        if(confirm('Whether to delete a '+tag.attr('data-user'))){
            $.post(
            "{{ url('root@deluser') }}",      //url地址
				{
					username:tag.attr('data-user'),
                    csrfmiddlewaretoken:'{{ csrf_token }}',
				},
				function(data){ //回传函数
					alert(data);
				},
				"text"
            )
        }else{

            }

    })
    $('body').on('click','#amend',function (e) {
        const tag = $(this);
        if(confirm('Whether to amend a '+tag.attr('data-user'))){
            $.get(
            "{{ url('root@amenduser') }}",      //url地址
				{
					username:tag.attr('data-user'),
				},
				function(data){ //回传函数
					$('.manage-msg').html($(data))
				},
				"html"
            )
        }else {

        }
    })
</script>

